import "server-only"; import { handleAgents24 } from "../../../../server/handler"; export const runtime = "nodejs"; export const dynamic = "force-dynamic"; export const maxDuration = 300; // Next development may construct Request URLs from its wildcard bind address. // Restore only that address from Host; the BFF still checks both Origin and Host. function handle(request: Request): Promise { const url = new URL(request.url); if (["0.0.0.0", "[::]"].includes(url.hostname)) { const host = request.headers.get("host"); try { if (!host) throw new Error("Missing Host"); const external = new URL(`${url.protocol}//${host}`); if (external.username || external.password || external.pathname !== "/" || external.search || external.hash) { throw new Error("Invalid Host"); } url.host = external.host; request = new Request(url, request); } catch { return Promise.resolve(new Response(null, { status: 403 })); } } return handleAgents24(request); } export const GET = handle; export const POST = handle; export const PUT = handle; export const PATCH = handle; export const DELETE = handle; export const HEAD = handle; export const OPTIONS = handle;